#ifndef WIDGET_H
#define WIDGET_H

#include <QWidget>

//typedef __int64 ssize_t;
#include "libvlc_include/vlc/vlc.h"

QT_BEGIN_NAMESPACE
namespace Ui { class Widget; }
QT_END_NAMESPACE

class Widget : public QWidget
{
    Q_OBJECT

public:
    Widget(QWidget *parent = nullptr);
    ~Widget();

    Q_INVOKABLE void onVlcMediaPlayerPlaying();
    Q_INVOKABLE void onVlcMediaPlayerTimeChanged();
    Q_INVOKABLE void onVlcMediaPlayerEndReached();
    Q_INVOKABLE void onVlcMediaPlayerStopped();

private Q_SLOTS:
    void on_btnOpen_clicked();
    void on_btnPlay_clicked();
    void on_btnStop_clicked();

    void on_horizontalSliderPlayer_valueChanged(int value);

protected:
    void resizeEvent(QResizeEvent* event);
    void mouseDoubleClickEvent(QMouseEvent* event);

private:
    static void vlcEvents(const libvlc_event_t* ev, void* param);
    static void vlcMediaEvents(const libvlc_event_t* event, void* userData);

    void setVideoAspectRatio(bool aspectRatio = true);
    void showMediaMetadata();

    //初始化速率选择comboBox控件
    void initSpeedComboBox();

private:
    Ui::Widget *ui;

    libvlc_instance_t*		m_vlcBase = nullptr;
    libvlc_media_t*			m_vlcMedia = nullptr;
    libvlc_media_player_t*	m_vlcMediaPlayer = nullptr;

    int m_defaultIndex;     //速率控件默认index
};
#endif // WIDGET_H
